package com.chaopei.order_mng.service.impl;

import com.chaopei.order_mng.entity.OrderInfo;
import com.chaopei.order_mng.mapper.OrderInfoMapper;
import com.chaopei.order_mng.service.OrderInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Corday 天涯
 * @Date 2022/5/11 22:47
 */
@Service
public class OrderInfoServiceImpl implements OrderInfoService {
    @Resource
    private OrderInfoMapper orderInfoMapper;

    /**
     * 此对象只传了uid,ordertime
     *
     * @param orderInfo
     * @return
     */
    @Override
    public int saveOrderInfo(OrderInfo orderInfo) {
        //添加成功后,返回记录条数
        int num = orderInfoMapper.insertOrderInfo(orderInfo);
        //拿到oid,订单详情表要使用
        int oid = num > 0 ? orderInfo.getId() : 0;
        return oid;
    }

    /**
     * @param uid
     * @return
     */
    @Override
    public List<Integer> queryOidsByUid(int uid) {
        return orderInfoMapper.selectOrderIdsByUid(uid);
    }
}
